import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.lang.Integer;
import static java.lang.Math.*;

public class NeighbouringNumbers {
	
	public static int indexNeighbouringNumbersOf(int[] array) {
		
		int distance = Integer.MAX_VALUE;
		int index = -1;
		
		for(int i = 0; i < array.length - 1; ++i) {
			int newDistance = abs(array[i] - array[i+1]);
			
			if(newDistance < distance) {
				index = i;
				distance = newDistance;
			}
		}
		
		return index;
	}
	
	public static void main(String[] args) {
		
		Scanner input = new Scanner(System.in);
		
		int length;
		int maxMember;
		
		System.out.print("Enter the length of array: ");
		length = input.nextInt();
		
		System.out.print("Enter the max posible member of array: ");
		maxMember = input.nextInt();
		
		int[] array = new int[length];
		
		Random rand = new Random(); 
		
		for(int i = 0; i < length; ++i) array[i] = rand.nextInt(maxMember); 
	
		int index = indexNeighbouringNumbersOf(array);
		
		System.out.format("%s - index = %s; distance = %s%n", Arrays.toString(array), index,  abs(array[index] - array[index + 1]));
	}
}